export function setItem(key, value) {
  if (typeof value === 'object') {
    value = JSON.stringify(value)
  }
  localStorage.setItem(key, value)
}
export function getItem(key) {
  const data = localStorage.getItem(key)
  // 尝试还原对象如果不是对象，直接走catch
  try {
    return JSON.parse(data)
  } catch (err) {
    return data
  }
}
export function removeItem(key) {
  localStorage.removeItem(key)
}
export function removeAllItem(key, value) {
  localStorage.clear()
}
